using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using System.IO;
using System.Collections;

namespace PropertyManagementFeatures
{
    class ListInstancesFeature : SPFeatureReceiver
    {
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            //throw new Exception("The method or operation is not implemented.");

            PopulatePropertyList();
            PopulateVendorList();
            PopulateFeeList();
            PopulatePropertyFeaturesList();
            PopulateRoomList();
            PopulateViewingAppointmentList();

            
        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            //throw new Exception("The method or operation is not implemented.");
        }

        public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        {
            //throw new Exception("The method or operation is not implemented.");
        }

        public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        {
            //throw new Exception("The method or operation is not implemented.");
        }

        protected void PopulatePropertyList()
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPFieldUserValue userValue = new SPFieldUserValue(web, web.CurrentUser.ID, web.CurrentUser.LoginName);

                    SPList list = web.Lists["Properties"];
                    SPListItem item = list.Items.Add();

                    item["Title"] = "9 John Street";
                    item["House_x0020_Number"] = "9";
                    item["Street_x0020_Line1"] = "John Street";
                    item["Street_x0020_Line2"] = "Lake Distract";
                    item["Town"] = "Hull";
                    item["Country"] = "UK";
                    item["Postcode"] = "HT1 4TW";

                    item["Property_x0020_Class"] = "Residential";
                    item["Property_x0020_Type"] = "Bungalow";
                    item["Ownership"] = "Freehold";
                    item["Property Area"] = "London";
                    item["Agent Branch"] = "London";

                    item["Property Description"] = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
                    item["Property Note"] = "";
                    item["Property_x0020_Type"] = "Offer Over";
                    item["Property Price"] = 230000;
                    item["Negotiator"] = userValue;
                    item["Require_x0020_Mortage"] = 1;
                    item["Preferred_x0020_Contact_x0020_me"] = "Phone";
                    item["Author"] = userValue;
                    item["Editor"] = userValue;

                    item.Update();

                    item = list.Items.Add();

                    item["Title"] = "15 Queens Square";
                    item["House_x0020_Number"] = "15";
                    item["Street_x0020_Line1"] = "Queens Square";
                    item["Street_x0020_Line2"] = "West Area";
                    item["Town"] = "Durham";
                    item["Country"] = "UK";
                    item["Postcode"] = "DD1 3RW";

                    item["Property_x0020_Class"] = "Residential";
                    item["Property_x0020_Type"] = "Bungalow";
                    item["Ownership"] = "Freehold";
                    item["Property Area"] = "London";
                    item["Agent Branch"] = "London";

                    item["Property Description"] = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
                    item["Property Note"] = "";
                    item["Property_x0020_Type"] = "Offer Over";
                    item["Property Price"] = 300000;
                    item["Negotiator"] = userValue;
                    item["Require_x0020_Mortage"] = 1;
                    item["Preferred_x0020_Contact_x0020_me"] = "Phone";
                    item["Author"] = userValue;
                    item["Editor"] = userValue;

                    item.Update();

                }
            }
        
        }

        protected void PopulateVendorList()
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPFieldUserValue userValue = new SPFieldUserValue(web, web.CurrentUser.ID, web.CurrentUser.LoginName);

                    SPList list = web.Lists["Vendors"];
                    SPListItem item = list.Items.Add();

                    item["Title"] = "Mr Mark Wilson";
                    item["House_x0020_Number"] = "9";
                    item["Street_x0020_Line1"] = "John Street";
                    item["Street_x0020_Line2"] = "Lake Distract";
                    item["Town"] = "Hull";
                    item["Country"] = "UK";
                    item["Postcode"] = "HT1 4TW";

                    item["Contact_x0020_Title"] = "Mr";
                    item["Surname"] = "Wilson";
                    item["FirstName"] = "Mark";
                    item["CellPhone"] = "07623123453";
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();

                    item["Title"] = "Ms Linda Lee";
                    item["House_x0020_Number"] = "9";
                    item["Street_x0020_Line1"] = "John Street";
                    item["Street_x0020_Line2"] = "Lake Distract";
                    item["Town"] = "Hull";
                    item["Country"] = "UK";
                    item["Postcode"] = "HT1 4TW";

                    item["Contact_x0020_Title"] = "Ms";
                    item["Surname"] = "Linda";
                    item["FirstName"] = "Lee";
                    item["CellPhone"] = "07612345678";
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();

                    item["Title"] = "Mr Andy Johnson";
                    item["House_x0020_Number"] = "9";
                    item["Street_x0020_Line1"] = "John Street";
                    item["Street_x0020_Line2"] = "Lake Distract";
                    item["Town"] = "Hull";
                    item["Country"] = "UK";
                    item["Postcode"] = "HT1 4TW";

                    item["Contact_x0020_Title"] = "Mr";
                    item["Surname"] = "Andy";
                    item["FirstName"] = "Johnson";
                    item["CellPhone"] = "07866668888";
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();


                }
            }

        }

        protected void PopulateFeeList()
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists["Fees"];
                    
                    SPListItem item = list.Items.Add();
                    item["Title"] = "Registration Fee";
                    item["Amount"] = 300;
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Survay";
                    item["Amount"] = 200;
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Floor Planning";
                    item["Amount"] = 150;
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Marketting";
                    item["Amount"] = 550;
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Search";
                    item["Amount"] = 150;
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Registration Fee";
                    item["Amount"] = 300;
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Survay";
                    item["Amount"] = 200;
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Floor Planning";
                    item["Amount"] = 150;
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Marketting";
                    item["Amount"] = 550;
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Search";
                    item["Amount"] = 150;
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                }
            }
        
        }

        protected void PopulatePropertyFeaturesList()
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists["Property Featurs"];

                    SPListItem item = list.Items.Add();
                    item["Title"] = "Open style staircase with wood handrail, newels";
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Open plan living, dining and kitchen";
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Large utility room for washing and drying";
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Contemporary sanitaryware by Ideal Standard";
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Contemporary sanitaryware by Ideal Standard";
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Large linen cupboard";
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Ground floor bedroom/study and shower/wc";
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Open style staircase with wood handrail, newels";
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Open plan living, dining and kitchen";
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Large utility room for washing and drying";
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                }
            }

        }

        protected void PopulateRoomList()
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists["Rooms"];

                    SPListItem item = list.Items.Add();
                    item["Title"] = "Bed Room 1";
                    item["Room_x0020_Type"] = "Bedroom";
                    item["Length_x0020__x0028_m_x0029_"] = "4.5";
                    item["Width_x0020__x0028_m_x0029_"] = "3.5";
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Bed Room 2";
                    item["Room_x0020_Type"] = "Bedroom";
                    item["Length_x0020__x0028_m_x0029_"] = "3.7";
                    item["Width_x0020__x0028_m_x0029_"] = "3.5";
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Bed Room 3";
                    item["Room_x0020_Type"] = "Bedroom";
                    item["Length_x0020__x0028_m_x0029_"] = "4.5";
                    item["Width_x0020__x0028_m_x0029_"] = "3.8";
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Living Room";
                    item["Room_x0020_Type"] = "Living Room";
                    item["Length_x0020__x0028_m_x0029_"] = "5.1";
                    item["Width_x0020__x0028_m_x0029_"] = "4.8";
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Kitchen";
                    item["Room_x0020_Type"] = "Kitchen";
                    item["Length_x0020__x0028_m_x0029_"] = "2.5";
                    item["Width_x0020__x0028_m_x0029_"] = "3.4";
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Bathroom";
                    item["Room_x0020_Type"] = "Bathroom";
                    item["Length_x0020__x0028_m_x0029_"] = "2.3";
                    item["Width_x0020__x0028_m_x0029_"] = "3.5";
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Kitchen";
                    item["Room_x0020_Type"] = "Kitchen";
                    item["Length_x0020__x0028_m_x0029_"] = "2.5";
                    item["Width_x0020__x0028_m_x0029_"] = "3.4";
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Living Room";
                    item["Room_x0020_Type"] = "Living Room";
                    item["Length_x0020__x0028_m_x0029_"] = "5.1";
                    item["Width_x0020__x0028_m_x0029_"] = "4.8";
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Bed Room 1";
                    item["Room_x0020_Type"] = "Bedroom";
                    item["Length_x0020__x0028_m_x0029_"] = "4.5";
                    item["Width_x0020__x0028_m_x0029_"] = "3.5";
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Bed Room 2";
                    item["Room_x0020_Type"] = "Bedroom";
                    item["Length_x0020__x0028_m_x0029_"] = "3.7";
                    item["Width_x0020__x0028_m_x0029_"] = "3.5";
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item.Update();

                }
            }
        }

        protected void PopulateViewingAppointmentList()
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPFieldUserValue userValue = new SPFieldUserValue(web, web.CurrentUser.ID, web.CurrentUser.LoginName);

                    SPList list = web.Lists["ViewingAppointments"];
                    SPListItem item = list.Items.Add();
                    item["Title"] = "Mr Peter Wilson";
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item["StartDate"] = DateTime.Today.AddDays(9).AddHours(16);
                    item["_EndDate"] = DateTime.Today.AddDays(9).AddHours(17);
                    item["CellPhone"] = "07623123453";
                    item["EMail"] = "LeeRee@hotmail.com";
                    item["Agent"] = userValue;
                    item["Author"] = userValue;
                    item["Editor"] = userValue;
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Mr Linda Johnson";
                    item["Property"] = new SPFieldLookupValue(1, "9 John Street, Lake Distract, Hull, HT1 4TW");
                    item["StartDate"] = DateTime.Today.AddDays(3).AddHours(11);
                    item["_EndDate"] = DateTime.Today.AddDays(3).AddHours(12);
                    item["CellPhone"] = "07432312323";
                    item["EMail"] = "Linda@hotmailtest.com";
                    item["Agent"] = userValue;
                    item["Author"] = userValue;
                    item["Editor"] = userValue;
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Mr Peter Johnson";
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item["StartDate"] = DateTime.Today.AddDays(1).AddHours(14);
                    item["_EndDate"] = DateTime.Today.AddDays(1).AddHours(16);
                    item["CellPhone"] = "07623123453";
                    item["EMail"] = "LeeRee@hotmail.com";
                    item["Agent"] = userValue;
                    item["Author"] = userValue;
                    item["Editor"] = userValue;
                    item.Update();

                    item = list.Items.Add();
                    item["Title"] = "Mr Emma Edison";
                    item["Property"] = new SPFieldLookupValue(2, "15 Queens Square, West Area, Durham, DD1 3RW");
                    item["StartDate"] = DateTime.Today.AddDays(5).AddHours(10);
                    item["_EndDate"] = DateTime.Today.AddDays(5).AddHours(11);
                    item["CellPhone"] = "07432312323";
                    item["EMail"] = "Linda@hotmailtest.com";
                    item["Agent"] = userValue;
                    item["Author"] = userValue;
                    item["Editor"] = userValue;
                    item.Update();
                }
            }

        }

        
    }
}
